"""
 -*- coding: utf-8-*-
 @File: page_manage_member.py
 @Author: chen
 @time: 2023/10/05/ 10:05
"""
import time

import allure
from appium.webdriver.common.appiumby import AppiumBy

from hogwartsHomework.homework_app_auto_L3.dev.pages.page_base import BasePage
from hogwartsHomework.homework_app_auto_L3.utils.mgt_log import logger


class MgtMemberPage(BasePage):
    """成员管理页面"""

    def goto_edit_member(self, name):
        """点击编辑按钮，进入编辑页面"""

        button_edit = (AppiumBy.XPATH, f'//*[@text="{name}"]/../../..//*[@resource-id="com.tencent.wework:id/jf4"]')
        with allure.step(f"点击成员【{name}】的编辑按钮"):
            logger.info(f"点击成员【{name}】的编辑按钮")
            self.do_click(button_edit)
        from hogwartsHomework.homework_app_auto_L3.dev.pages.page_edit_member import EditMemberPage
        logger.info("进入成员编辑页面")
        return EditMemberPage(self.driver)

    def back_to_contact_list(self):
        button_close = (AppiumBy.ID, 'com.tencent.wework:id/ll9')
        with allure.step("点击关闭按钮"):
            logger.info("点击关闭按钮")
            self.do_click(button_close)
        from hogwartsHomework.homework_app_auto_L3.dev.pages.page_contact_list import ContactListPage
        logger.info("进入通讯录页面")
        # time.sleep(5)
        return ContactListPage(self.driver)
